//
//  STEnchaseViewController.swift
//  SeaTransportManage
//
//  Created by guopengwen on 2021/11/27.
//

import UIKit

// 装箱拍照指引  img_enchase_
class STEnchaseViewController: GPBaseViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setNavBarTitle("装箱拍照提供标准")
        addSubviewForPage()
    }

    func addSubviewForPage() {
        addTopBGView()
        
        let img_w = ( kScreenWidth - 45 ) / 2
        let h1 = 144 * img_w / 164.5
        let h2 = 198.66 * img_w / 164.5
        
        let scrollView = UIScrollView.init(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth, height: view.bounds.size.height))
        scrollView.backgroundColor = UIColor.init(hexString: "#FFFFFF", alpha: 0)
        scrollView.contentSize = CGSize.init(width: kScreenWidth, height: 84 + 249 + h1 + 4 * h2)
        view.addSubview(scrollView)
        
        let title_1: UILabel = UILabel.init(frame: CGRect.init(x: 16, y: 13, width: kScreenWidth - 32, height: 33))
        title_1.text = "1.地板照（不少于3张）"
        title_1.textColor = UIColor.white
        title_1.font = UIFont.systemFont(ofSize: 24, weight: UIFont.Weight.bold)
        scrollView.addSubview(title_1)
        
        var img_arr: Array<UIImageView> = Array();
        var i = 1
        while (i < 10) {
            let img = UIImageView.init(image: UIImage.init(named: "img_enchase_".appending(String(i))))
            
            scrollView.addSubview(img)
            img_arr.append(img)
            i += 1
        }
      
        img_arr[0].frame = CGRect.init(x: 16, y: 64, width: img_w, height: h1)
        img_arr[1].frame = CGRect.init(x: img_w + 30, y: 64, width: img_w, height: h1)
        
        let title_2: UILabel = UILabel.init(frame: CGRect.init(x: 13, y: 88 + h1, width: kScreenWidth - 28, height: 33))
        title_2.numberOfLines = 0
        let attrString = NSMutableAttributedString(string: "2.空箱照（需要完整体现箱内状态以及侧边箱号）")
        let strSubAttr1: [NSMutableAttributedString.Key: Any] = [.font: UIFont(name: "苹方-简", size: 24),.foregroundColor: UIColor(red: 0.2, green: 0.2, blue: 0.2,alpha:1)]
        attrString.addAttributes(strSubAttr1, range: NSRange(location: 0, length: 5))

        let strSubAttr2: [NSMutableAttributedString.Key: Any] = [.font: UIFont(name: "苹方-简", size: 14),.foregroundColor: UIColor(red: 0.2, green: 0.2, blue: 0.2,alpha:1)]
        attrString.addAttributes(strSubAttr2, range: NSRange(location: 5, length: 18))
        title_2.attributedText = attrString
        scrollView.addSubview(title_2)
        
        img_arr[2].frame = CGRect.init(x: 16, y: 139 + h1, width: img_w, height: h2)
        
        let title_3: UILabel = UILabel.init(frame: CGRect.init(x: 16, y: 163 + h1 + h2, width: kScreenWidth - 32, height: 50))
        title_3.numberOfLines = 0
        let attrString_3 = NSMutableAttributedString(string: "3.装载情况照片（不同规则货物每装载一至两\n排都要拍照）")
        
        let attrString_3_1: [NSMutableAttributedString.Key: Any] = [.font: UIFont(name: "苹方-简", size: 24),.foregroundColor: UIColor(red: 0.2, green: 0.2, blue: 0.2,alpha:1)]
        attrString_3.addAttributes(attrString_3_1, range: NSRange(location: 0, length: 8))

        let attrString_3_2: [NSMutableAttributedString.Key: Any] = [.font: UIFont(name: "苹方-简", size: 14),.foregroundColor: UIColor(red: 0.2, green: 0.2, blue: 0.2,alpha:1)]
        attrString_3.addAttributes(attrString_3_2, range: NSRange(location: 8, length: attrString.length - 7))
        title_3.attributedText = attrString_3
        scrollView.addSubview(title_3)

        img_arr[3].frame = CGRect.init(x: 16, y: 225 + h1 + h2, width:img_w, height: h2)
        img_arr[4].frame = CGRect.init(x:30 + img_w, y: 225 + h1 + h2, width:img_w, height: h2)
        
        img_arr[5].frame = CGRect.init(x: 16, y: 237 + h1 + 2 * h2, width:img_w, height: h2)
        img_arr[6].frame = CGRect.init(x: 30 + img_w, y: 237 + h1 + 2 * h2, width:img_w, height: h2)
        
        img_arr[7].frame = CGRect.init(x: 16, y: 249 + h1 + 3 * h2, width:img_w, height: h2)
        img_arr[8].frame = CGRect.init(x: 30 + img_w, y:249 + h1 + 3 * h2, width:img_w, height: h2)
    }

}
